#ifndef __RINGBUF_H__
#define __RINGBUF_H__
#include <atomic>
namespace mdk
{
    class CCycleBuffer
    {
    public:
        bool isFull();
        bool isEmpty();
        void empty();
        int getReadableLength();
        int getWriteableLength();
        CCycleBuffer(int size);
        virtual ~CCycleBuffer();
        int write(char *buf, int count);
        int read(char *buf, int count);
        int getStart()
        {
            return m_nReadPos;
        }
        int getEnd()
        {
            return m_nWritePos;
        }

    private:
        std::atomic_bool m_bEmpty, m_bFull;
        char *m_pBuf;
        int m_nBufSize;
        std::atomic_int m_nReadPos;
        std::atomic_int m_nWritePos;
        //std::mutex m_mutex;
        int test;
    };
}
#endif